package com.api.user.controller;

import com.api.core.annotation.PowerEnable;
import com.api.core.controller.Ctrl;
import com.api.core.response.Result;
import com.api.user.model.Identification;
import com.api.user.service.IdentificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;



/**
* Created by wanghuiwen on 2021/03/23.
*/
@PowerEnable(name = "Identification",url = "/identification")
@Api(value = "Identification", tags = {"Identification"})
@RestController
@RequestMapping("/identification")
public class IdentificationController extends Ctrl{
    @Resource
    private IdentificationService identificationService;

    @ApiOperation(value = "用户提交认证信息", tags = {"Identification"}, notes = "用户提交认证信息")
    @PostMapping(value="/save",name="用户提交认证信息")
    public Result add(@ApiParam Identification identification, Authentication authentication) {
        Long userId = getAuthUser(authentication).getId();
        identification.setUserId(userId);
        identification.setCreateTime(new Date().getTime());
        return identificationService.add(identification);
    }



    @ApiOperation(value = "Identification列表信息", tags = {"Identification"}, notes = "Identification列表信息")
    @PostMapping(value = "/list", name = "Identification列表信息")
    public Result list(@RequestParam(defaultValue = "{}") String search,
                       @RequestParam(defaultValue = "{}") String order,
                       Long userId) {
        return identificationService.list(search, order,userId);
    }


}
